#include "Utils.h"
#include "ListNode.h"
#include "TreeNode.h"
#include <iostream>
#include <vector>
#include <string>
#include <sstream>

using namespace std;

class Issue299 {
public:
	string getHint(string secret, string guess) {
		vector<int> countList(10,0);
		for (int i=0;i<secret.length();++i)
		{
			int num=secret[i]-'0';
			int cnt=countList[num];
			countList[num]=cnt+1;
		}
		int bullsAndCows=0;
		for (int i=0;i<guess.length();++i)
		{
			int num=guess[i]-'0';
			int cnt=countList[num];
			if (cnt>0)
				bullsAndCows++;
			countList[num]=cnt-1;
		}
		int bulls=0;
		for (int i=0;i<secret.length();++i)
		{
			if (secret[i]==guess[i])
				bulls++;
		}

		string hint;
		stringstream sstm;
		sstm << bulls << "A"<<(bullsAndCows-bulls)<<"B";
		hint=sstm.str();
		return hint;
	}
};

int main299(){

	Issue299 sol;
	string secret="1807";
	string guess="6810";
	string hint=sol.getHint(secret,guess);
	cout<<hint<<endl;
	return 0;
}